package com.lccviolet;

import java.nio.ByteBuffer;

/**
 * @author LiChaochao
 * @Date 2021/9/24 20:53
 * @Description DirectBufferMemory 直接内存溢出 NIO会报
 * -Xms10m -Xmx10m -XX:+PrintGCDetails -XX:MaxDirectMemorySize=5m
 */
public class DirectBufferMemoryDemo {
    public static void main(String[] args) {
        // JVM内存默认约为本机内存的1/4
        System.out.println("配置的maxDirectMemorySize：" +
                (sun.misc.VM.maxDirectMemory() / (double)1024 / 1024) + "MB");

        ByteBuffer byteBuffer = ByteBuffer.allocateDirect(6 * 1024 * 1024);

    }
}
